#!/bin/bash

# 设置串口权限
echo "设置串口权限..."
sudo cp 99-serial.rules /etc/udev/rules.d/
sudo udevadm control --reload-rules
sudo udevadm trigger

# 配置pigpiod服务
echo "配置pigpiod服务..."
sudo cp pigpiod.service /etc/systemd/system/
sudo systemctl daemon-reload
sudo systemctl enable pigpiod
sudo systemctl start pigpiod

# 检查服务状态
echo "检查服务状态..."
sudo systemctl status pigpiod

# 检查串口权限
echo "检查串口权限..."
ls -l /dev/ttyS0

echo "环境初始化完成！" 